{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport * as React from 'react';\nimport { useRef, useLayoutEffect } from 'react';\nimport classNames from 'classnames';\nimport { scrollTo, waitElementReady } from \"../../utils/uiUtil\";\nimport PanelContext from \"../../PanelContext\";\nfunction TimeUnitColumn(props) {\n  var prefixCls = props.prefixCls,\n    units = props.units,\n    onSelect = props.onSelect,\n    value = props.value,\n    active = props.active,\n    hideDisabledOptions = props.hideDisabledOptions;\n  var cellPrefixCls = \"\".concat(prefixCls, \"-cell\");\n  var _React$useContext = React.useContext(PanelContext),\n    open = _React$useContext.open;\n  var ulRef = useRef(null);\n  var liRefs = useRef(new Map());\n  var scrollRef = useRef(); // `useLayoutEffect` here to avoid blink by duration is 0\n\n  useLayoutEffect(function () {\n    var li = liRefs.current.get(value);\n    if (li && open !== false) {\n      scrollTo(ulRef.current, li.offsetTop, 120);\n    }\n  }, [value]);\n  useLayoutEffect(function () {\n    if (open) {\n      var li = liRefs.current.get(value);\n      if (li) {\n        scrollRef.current = waitElementReady(li, function () {\n          scrollTo(ulRef.current, li.offsetTop, 0);\n        });\n      }\n    }\n    return function () {\n      var _scrollRef$current;\n      (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.call(scrollRef);\n    };\n  }, [open]);\n  return /*#__PURE__*/React.createElement(\"ul\", {\n    className: classNames(\"\".concat(prefixCls, \"-column\"), _defineProperty({}, \"\".concat(prefixCls, \"-column-active\"), active)),\n    ref: ulRef,\n    style: {\n      position: 'relative'\n    }\n  }, units.map(function (unit) {\n    var _classNames2;\n    if (hideDisabledOptions && unit.disabled) {\n      return null;\n    }\n    return /*#__PURE__*/React.createElement(\"li\", {\n      key: unit.value,\n      ref: function ref(element) {\n        liRefs.current.set(unit.value, element);\n      },\n      className: classNames(cellPrefixCls, (_classNames2 = {}, _defineProperty(_classNames2, \"\".concat(cellPrefixCls, \"-disabled\"), unit.disabled), _defineProperty(_classNames2, \"\".concat(cellPrefixCls, \"-selected\"), value === unit.value), _classNames2)),\n      onClick: function onClick() {\n        if (unit.disabled) {\n          return;\n        }\n        onSelect(unit.value);\n      }\n    }, /*#__PURE__*/React.createElement(\"div\", {\n      className: \"\".concat(cellPrefixCls, \"-inner\")\n    }, unit.label));\n  }));\n}\nexport default TimeUnitColumn;","map":{"version":3,"names":["_defineProperty","React","useRef","useLayoutEffect","classNames","scrollTo","waitElementReady","PanelContext","TimeUnitColumn","props","prefixCls","units","onSelect","value","active","hideDisabledOptions","cellPrefixCls","concat","_React$useContext","useContext","open","ulRef","liRefs","Map","scrollRef","li","current","get","offsetTop","_scrollRef$current","call","createElement","className","ref","style","position","map","unit","_classNames2","disabled","key","element","set","onClick","label"],"sources":["/data/messenger.client/node_modules/rc-picker/es/panels/TimePanel/TimeUnitColumn.js"],"sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport * as React from 'react';\nimport { useRef, useLayoutEffect } from 'react';\nimport classNames from 'classnames';\nimport { scrollTo, waitElementReady } from \"../../utils/uiUtil\";\nimport PanelContext from \"../../PanelContext\";\n\nfunction TimeUnitColumn(props) {\n  var prefixCls = props.prefixCls,\n      units = props.units,\n      onSelect = props.onSelect,\n      value = props.value,\n      active = props.active,\n      hideDisabledOptions = props.hideDisabledOptions;\n  var cellPrefixCls = \"\".concat(prefixCls, \"-cell\");\n\n  var _React$useContext = React.useContext(PanelContext),\n      open = _React$useContext.open;\n\n  var ulRef = useRef(null);\n  var liRefs = useRef(new Map());\n  var scrollRef = useRef(); // `useLayoutEffect` here to avoid blink by duration is 0\n\n  useLayoutEffect(function () {\n    var li = liRefs.current.get(value);\n\n    if (li && open !== false) {\n      scrollTo(ulRef.current, li.offsetTop, 120);\n    }\n  }, [value]);\n  useLayoutEffect(function () {\n    if (open) {\n      var li = liRefs.current.get(value);\n\n      if (li) {\n        scrollRef.current = waitElementReady(li, function () {\n          scrollTo(ulRef.current, li.offsetTop, 0);\n        });\n      }\n    }\n\n    return function () {\n      var _scrollRef$current;\n\n      (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.call(scrollRef);\n    };\n  }, [open]);\n  return /*#__PURE__*/React.createElement(\"ul\", {\n    className: classNames(\"\".concat(prefixCls, \"-column\"), _defineProperty({}, \"\".concat(prefixCls, \"-column-active\"), active)),\n    ref: ulRef,\n    style: {\n      position: 'relative'\n    }\n  }, units.map(function (unit) {\n    var _classNames2;\n\n    if (hideDisabledOptions && unit.disabled) {\n      return null;\n    }\n\n    return /*#__PURE__*/React.createElement(\"li\", {\n      key: unit.value,\n      ref: function ref(element) {\n        liRefs.current.set(unit.value, element);\n      },\n      className: classNames(cellPrefixCls, (_classNames2 = {}, _defineProperty(_classNames2, \"\".concat(cellPrefixCls, \"-disabled\"), unit.disabled), _defineProperty(_classNames2, \"\".concat(cellPrefixCls, \"-selected\"), value === unit.value), _classNames2)),\n      onClick: function onClick() {\n        if (unit.disabled) {\n          return;\n        }\n\n        onSelect(unit.value);\n      }\n    }, /*#__PURE__*/React.createElement(\"div\", {\n      className: \"\".concat(cellPrefixCls, \"-inner\")\n    }, unit.label));\n  }));\n}\n\nexport default TimeUnitColumn;"],"mappings":"AAAA,OAAOA,eAAe,MAAM,2CAA2C;AACvE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,MAAM,EAAEC,eAAe,QAAQ,OAAO;AAC/C,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,QAAQ,EAAEC,gBAAgB,QAAQ,oBAAoB;AAC/D,OAAOC,YAAY,MAAM,oBAAoB;AAE7C,SAASC,cAAc,CAACC,KAAK,EAAE;EAC7B,IAAIC,SAAS,GAAGD,KAAK,CAACC,SAAS;IAC3BC,KAAK,GAAGF,KAAK,CAACE,KAAK;IACnBC,QAAQ,GAAGH,KAAK,CAACG,QAAQ;IACzBC,KAAK,GAAGJ,KAAK,CAACI,KAAK;IACnBC,MAAM,GAAGL,KAAK,CAACK,MAAM;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